import requests


def load_web_content(url):
    """步骤1：爬取网页HTML内容"""
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
        "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    }
    try:
        response = requests.get(url, headers=headers, timeout=10)
        # 自动识别编码，避免乱码
        response.encoding = response.apparent_encoding
        return response.text, url
    except Exception as e:
        raise ValueError(f"爬取网页失败：{str(e)}")